<!-- 头部 -->
{include file="public/top" /}
<!-- /头部 -->
<div class="main-container" id="main-container">
    <!-- left -->
    {include file="public/left" /}
    <!-- /left -->
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li>
                        <i class="ace-icon fa fa-home home-icon"></i> <a href="#">首页</a>
                    </li>
                    <li><a href="#">用户管理</a></li>
                    <li class="active">用户列表</li>
                </ul>
                <!-- /.nav-search -->
            </div>
            <div class="page-content">
                <div class="page-header">
                    <div class="row">
                        <div class="col-md-6">
                            <h1>
                                用户列表
                                <small>
                                    <i class="ace-icon fa fa-angle-double-right"></i>
                                    查看管理用户列表
                                </small>
                            </h1>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="page-header">
                            <div class="row">
                                <div class="col-md-6">
                                    <button type="button" class="btn  btn-info btn-sm btn-round" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">新增会员</button>


                                    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
                                        <div class="modal-dialog" role="document">
                                            <div class="modal-content" style="width:350px;margin:180px auto" >
                                                <div class="modal-body">
                                                    <form action="{:url('user/add')}" method="POST" id="addsubmit" onsubmit="return validate(this)">
                                                        <div class="form-group" >
                                                            <label  for class="control-label ml35">用户名:</label>
                                                            <input type="text" class="form-control inputstyle" id="addusername" name="username" >
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label ml35">密码:</label>
                                                            <input type="text" class="form-control inputstyle" id="adduserpwd" name="password" >
                                                        </div>
                                                        <div class="form-group">
                                                            <label  class="control-label ml35 ">用户组:</label>
                                                            <select name="user_type" id="user_type" class="form-control inputstyle" >
                                                                <option value="1">普通会员</option>
                                                                <option value="2">管理员</option>
                                                            </select>
                                                        </div>
                                                        <div class="modal-footer" style="background-color: #fff;text-align: center">
                                                            <button type="button" class="btn btn-default  btn-default btn-round " data-dismiss="modal">关闭</button>&nbsp;&nbsp;&nbsp;
                                                            <button type="submit" class="btn btn-default  btn-info btn-round ">提交</button>
                                                        </div>
                                                    </form>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div><!-- /.page-header -->

                            <table cellspacing="0" cellpadding="0" width="100%" class="table table-striped table-bordered table-hover">
                                <tbody>
                                    <tr>
                                        <th>UID</th>
                                        <th>用户名</th>
                                        <th>用户组</th>
                                        <th>创建时间</th>
                                        <th>操作</th>
                                    </tr>
                                    <!--数据行-->
                                    {if empty($userlist)}
                                        <tr><td colspan="5" align="center" style="height:60px;color:#666;">暂无数据</td></tr>
                                    {else/}
                                    {volist name='userlist' id='vo'}
                                    <tr>
                                        <td>{$vo.uid}</td>
                                        <td>{$vo.username}</td>
                                        <td>{$vo.user_type}</td>
                                        <td>{$vo.create_time}</td>
                                        <td>
                                            <div>
                                            <button type="button" class="btn btn-mini  btn-info btn-round" data-toggle="modal" data-target="#exampleModal{$vo.uid}" data-whatever="@mdo"><i class="ace-icon fa fa-pencil-square-o "></i>编辑</button>
                                            <div class="modal fade" id="exampleModal{$vo.uid}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
                                                <div class="modal-dialog" role="document">
                                                    <div class="modal-content" style="width:350px;margin:180px auto" >
                                                        <div class="modal-body">
                                                                <form action="{:url('user/edit')}" method="post" id="editsubmit" onsubmit="return edit_validate(this)">
                                                                <div class="form-group">
                                                                    <label  class="control-label ml35">用户名:</label>
                                                                    <input type="text" class="form-control inputstyle" id="editusername" name="username" value="{$vo.username}" >
                                                                </div>
                                                                <div class="form-group">
                                                                    <label  class="control-label ml35">密码:</label>
                                                                    <input type="text" class="form-control inputstyle"  name="password" value="" >
                                                                </div>
                                                                <div class="form-group">
                                                                    <label  class="control-label ml35">用户组:</label>
                                                                    <select name="user_type" id="edit_user_type" class="form-control inputstyle" >
                                                                        <option value="1" {if condition="$vo.user_type eq 1"} selected{/if} >普通会员</option>
                                                                        <option value="2" {if condition="$vo.user_type eq 2"} selected{/if} >管理员</option>
                                                                        {if condition="$vo.user_type eq 3"}<option value="3"  selected>超级管理员</option> {/if}
                                                                    </select>
                                                                </div>
                                                                    <input type="hidden" name="uid" value="{$vo.uid}">
                                                                <div class="modal-footer" style="background-color: #fff;text-align: center">
                                                                    <button type="button" class="btn btn-default  btn-default btn-round" data-dismiss="modal">关闭</button>&nbsp;&nbsp;&nbsp;
                                                                    <button type="submit" class="btn btn-default  btn-info btn-round">提交</button>
                                                                </div>
                                                            </form>
                                                        </div>

                                                    </div>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                {/volist}
                                {/if}
                                </tbody>
                            </table>
                        {$multipage}
                    </div>
                </div>
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<script>

    function validate (theform){
        var addusername = $('#addusername').val();
        var adduserpwd = $('#adduserpwd').val();
        if(addusername == '' ){
            Msg('用户名不能为空');
            return false;
        }
        if(adduserpwd == '' ){
            Msg('密码不能为空');
            return false;
        }
        return true;
    }
    function edit_validate (theform){
        var editusername = $('#editusername').val();
        var editpwd = $('#editpwd').val();

        if(editusername == '' ){
            Msg('用户名不能为空');
            return false;
        }
        if(editpwd == '' ){
            Msg('密码不能为空');
            return false;
        }
        return true;
    }


</script>